<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Get model snapshots API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'ml-get-snapshot.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-get-snapshot.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-get-snapshot.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/ml-get-snapshot.html" rel="nofollow" target="_blank">../en/ml-get-snapshot.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="ml-apis.html">Machine learning anomaly detection APIs</a></span>
»
<span class="breadcrumb-node">Get model snapshots API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="get-ml-info.html">« Get machine learning info API</a>
</span>
<span class="next">
<a href="ml-get-overall-buckets.html">Get overall buckets API »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="ml-get-snapshot"></a>Get model snapshots API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-snapshot.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>

<p>Retrieves information about model snapshots.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-snapshot-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-snapshot.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">GET _ml/anomaly_detectors/&lt;job_id&gt;/model_snapshots</code><br></p>
<p><code class="literal">GET _ml/anomaly_detectors/&lt;job_id&gt;/model_snapshots/&lt;snapshot_id&gt;</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-snapshot-prereqs"></a>Prerequisites<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-snapshot.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
If the Elasticsearch security features are enabled, you must have <code class="literal">monitor_ml</code>,
<code class="literal">monitor</code>, <code class="literal">manage_ml</code>, or <code class="literal">manage</code> cluster privileges to use this API. See
<a class="xref" href="security-privileges.html" title="Security privileges">Security privileges</a>.
</li>
</ul>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-snapshot-path-parms"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-snapshot.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;job_id&gt;</code>
</span>
</dt>
<dd>
(Required, string)
Identifier for the anomaly detection job.
</dd>
<dt>
<span class="term">
<code class="literal">&lt;snapshot_id&gt;</code>
</span>
</dt>
<dd>
<p>
(Optional, string)
A numerical character string that uniquely identifies the model snapshot.
</p>
<p>If you do not specify this optional parameter, the API returns information about
all model snapshots.</p>
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-snapshot-request-body"></a>Request body<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-snapshot.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">desc</code>
</span>
</dt>
<dd>
(Optional, boolean) If true, the results are sorted in descending order.
</dd>
<dt>
<span class="term">
<code class="literal">end</code>
</span>
</dt>
<dd>
(Optional, date) Returns snapshots with timestamps earlier than this time.
</dd>
<dt>
<span class="term">
<code class="literal">from</code>
</span>
</dt>
<dd>
(Optional, integer) Skips the specified number of snapshots.
</dd>
<dt>
<span class="term">
<code class="literal">size</code>
</span>
</dt>
<dd>
(Optional, integer) Specifies the maximum number of snapshots to obtain.
</dd>
<dt>
<span class="term">
<code class="literal">sort</code>
</span>
</dt>
<dd>
(Optional, string) Specifies the sort field for the requested snapshots. By
default, the snapshots are sorted by their timestamp.
</dd>
<dt>
<span class="term">
<code class="literal">start</code>
</span>
</dt>
<dd>
(Optional, string) Returns snapshots with timestamps after this time.
</dd>
</dl>
</div>
</div>

<div class="section child_attributes">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-snapshot-results"></a>Response body<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-snapshot.asciidoc">edit</a>
</h3>
</div></div></div>
<p>The API returns an array of model snapshot objects, which have the following
properties:</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">description</code>
</span>
</dt>
<dd>
(string) An optional description of the job.
</dd>
<dt>
<span class="term">
<code class="literal">job_id</code>
</span>
</dt>
<dd>
(string) A numerical character string that uniquely identifies the job that
the snapshot was created for.
</dd>
<dt>
<span class="term">
<code class="literal">latest_record_time_stamp</code>
</span>
</dt>
<dd>
(date) The timestamp of the latest processed record.
</dd>
<dt>
<span class="term">
<code class="literal">latest_result_time_stamp</code>
</span>
</dt>
<dd>
(date) The timestamp of the latest bucket result.
</dd>
<dt>
<span class="term">
<code class="literal">min_version</code>
</span>
</dt>
<dd>
(string) The minimum version required to be able to restore the model snapshot.
</dd>
</dl>
</div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">model_size_stats</code>
</span>
</dt>
<dd>
<p>
(object) Summary information describing the model.
</p>
<details open>
<summary class="title">Properties of <code class="literal">model_size_stats</code></summary>
<div class="content">
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">bucket_allocation_failures_count</code>
</span>
</dt>
<dd>
(long) The number of buckets for which entities were not processed due to memory
limit constraints.
</dd>
<dt>
<span class="term">
<code class="literal">categorized_doc_count</code>
</span>
</dt>
<dd>
(long) The number of documents that have had a field categorized.
</dd>
<dt>
<span class="term">
<code class="literal">categorization_status</code>
</span>
</dt>
<dd>
<p>
(string) The status of categorization for this job.
Contains one of the following values.
</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal">ok</code>: Categorization is performing acceptably well (or not being
used at all).
</li>
<li class="listitem">
<code class="literal">warn</code>: Categorization is detecting a distribution of categories
that suggests the input data is inappropriate for categorization.
Problems could be that there is only one category, more than 90% of
categories are rare, the number of categories is greater than 50% of
the number of categorized documents, there are no frequently
matched categories, or more than 50% of categories are dead.
</li>
</ul>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">dead_category_count</code>
</span>
</dt>
<dd>
(long) The number of categories created by categorization that will
never be assigned again because another category’s definition
makes it a superset of the dead category.  (Dead categories are a
side effect of the way categorization has no prior training.)
</dd>
<dt>
<span class="term">
<code class="literal">frequent_category_count</code>
</span>
</dt>
<dd>
(long) The number of categories that match more than 1% of categorized
documents.
</dd>
<dt>
<span class="term">
<code class="literal">job_id</code>
</span>
</dt>
<dd>
(string)
Identifier for the anomaly detection job.
</dd>
<dt>
<span class="term">
<code class="literal">log_time</code>
</span>
</dt>
<dd>
(date) The timestamp that the <code class="literal">model_size_stats</code> were recorded, according to
server-time.
</dd>
<dt>
<span class="term">
<code class="literal">memory_status</code>
</span>
</dt>
<dd>
<p>
(string) The status of the memory in relation to its <code class="literal">model_memory_limit</code>.
Contains one of the following values.
</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal">hard_limit</code>: The internal models require more space that the configured
memory limit. Some incoming data could not be processed.
</li>
<li class="listitem">
<code class="literal">ok</code>: The internal models stayed below the configured value.
</li>
<li class="listitem">
<code class="literal">soft_limit</code>: The internal models require more than 60% of the configured
memory limit and more aggressive pruning will be performed in order to try to
reclaim space.
</li>
</ul>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">model_bytes</code>
</span>
</dt>
<dd>
(long) An approximation of the memory resources required for this analysis.
</dd>
<dt>
<span class="term">
<code class="literal">model_bytes_exceeded</code>
</span>
</dt>
<dd>
(long) The number of bytes over the high limit for memory usage at the last allocation failure.
</dd>
<dt>
<span class="term">
<code class="literal">model_bytes_memory_limit</code>
</span>
</dt>
<dd>
(long) The upper limit for memory usage, checked on increasing values.
</dd>
<dt>
<span class="term">
<code class="literal">rare_category_count</code>
</span>
</dt>
<dd>
(long) The number of categories that match just one categorized document.
</dd>
<dt>
<span class="term">
<code class="literal">result_type</code>
</span>
</dt>
<dd>
(string) Internal. This value is always <code class="literal">model_size_stats</code>.
</dd>
<dt>
<span class="term">
<code class="literal">timestamp</code>
</span>
</dt>
<dd>
(date) The timestamp that the <code class="literal">model_size_stats</code> were recorded, according to the
bucket timestamp of the data.
</dd>
<dt>
<span class="term">
<code class="literal">total_by_field_count</code>
</span>
</dt>
<dd>
(long) The number of <em>by</em> field values analyzed. Note that these are counted
separately for each detector and partition.
</dd>
<dt>
<span class="term">
<code class="literal">total_category_count</code>
</span>
</dt>
<dd>
(long) The number of categories created by categorization.
</dd>
<dt>
<span class="term">
<code class="literal">total_over_field_count</code>
</span>
</dt>
<dd>
(long) The number of <em>over</em> field values analyzed. Note that these are counted
separately for each detector and partition.
</dd>
<dt>
<span class="term">
<code class="literal">total_partition_field_count</code>
</span>
</dt>
<dd>
(long) The number of <em>partition</em> field values analyzed.
</dd>
</dl>
</div>
</div>
</details>
</dd>
<dt>
<span class="term">
<code class="literal">retain</code>
</span>
</dt>
<dd>
(boolean)
If <code class="literal">true</code>, this snapshot will not be deleted during automatic cleanup of
snapshots older than <code class="literal">model_snapshot_retention_days</code>. However, this snapshot
will be deleted when the job is deleted. The default value is <code class="literal">false</code>.
</dd>
<dt>
<span class="term">
<code class="literal">snapshot_id</code>
</span>
</dt>
<dd>
(string)
A numerical character string that uniquely identifies the model snapshot.
</dd>
<dt>
<span class="term">
<code class="literal">snapshot_doc_count</code>
</span>
</dt>
<dd>
(long) For internal use only.
</dd>
<dt>
<span class="term">
<code class="literal">timestamp</code>
</span>
</dt>
<dd>
(date) The creation timestamp for the snapshot.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-snapshot-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-snapshot.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET _ml/anomaly_detectors/high_sum_total_sales/model_snapshots
{
  "start": "1575402236000"
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1827.console"></div>
<p>In this example, the API provides a single result:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">{
  "count" : 1,
  "model_snapshots" : [
    {
      "job_id" : "high_sum_total_sales",
      "min_version" : "6.4.0",
      "timestamp" : 1575402237000,
      "description" : "State persisted due to job close at 2019-12-03T19:43:57+0000",
      "snapshot_id" : "1575402237",
      "snapshot_doc_count" : 1,
      "model_size_stats" : {
        "job_id" : "high_sum_total_sales",
        "result_type" : "model_size_stats",
        "model_bytes" : 1638816,
        "model_bytes_exceeded" : 0,
        "model_bytes_memory_limit" : 10485760,
        "total_by_field_count" : 3,
        "total_over_field_count" : 3320,
        "total_partition_field_count" : 2,
        "bucket_allocation_failures_count" : 0,
        "memory_status" : "ok",
        "categorized_doc_count" : 0,
        "total_category_count" : 0,
        "frequent_category_count" : 0,
        "rare_category_count" : 0,
        "dead_category_count" : 0,
        "categorization_status" : "ok",
        "log_time" : 1575402237000,
        "timestamp" : 1576965600000
      },
      "latest_record_time_stamp" : 1576971072000,
      "latest_result_time_stamp" : 1576965600000,
      "retain" : false
    }
  ]
}</pre>
</div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="get-ml-info.html">« Get machine learning info API</a>
</span>
<span class="next">
<a href="ml-get-overall-buckets.html">Get overall buckets API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>